package com.tencent.wxcloudrun.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class BusinessException extends RuntimeException {
    Object data;
    String code;
    Object[] args;

    public BusinessException(String message) {
        super(message);
    }

    public BusinessException(String message, Throwable cause) {
        super(message, cause);
    }

    public BusinessException(String code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(String code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }

    public static BusinessException builder(String message) {
        return new BusinessException(message);
    }

    public static BusinessException builder(String message, Throwable cause) {
        return new BusinessException(message, cause);
    }

    public static BusinessException builder(String code, String message) {
        return new BusinessException(code, message);
    }

    public static BusinessException builder(String code, String message, Throwable cause) {
        return new BusinessException(code, message, cause);
    }

    public BusinessException data(Object data) {
        this.data = data;
        return this;
    }

    public BusinessException code(String code) {
        this.code = code;
        return this;
    }

    public BusinessException args(Object... args) {
        this.args = args;
        return this;
    }
}
